From: Keir Fraser Date: Sat, 5 Mar 2011 11:36:21 +0000 (+0000) Subject: sched_credit: Hold lock while dump scheduler info X-Git-Url: https://dgit.raspbian.org/%22http:/www.example.com/cgi/%22https://%22%22/%22http:/www.example.com/cgi/%22https:/%22%22?a=commitdiff_plain;h=e00d02009db149c6b9ee52da9d0907e9fe362a23;p=xen.git sched_credit: Hold lock while dump scheduler info Dump runq with debug key 'r' may cause dead loop like below: (XEN) active vcpus: (XEN) 1: [1.0] pri=0 flags=0 cpu=0 credit=263 [w=256] (XEN) 2: [0.2] pri=0 flags=0 cpu=5 credit=284 [w=256] (XEN) 3: [0.2] pri=0 flags=0 cpu=5 credit=282 [w=256] ... (XEN) xxxxx: [0.2] pri=0 flags=0 cpu=2 credit=54 [w=256] ... (XEN) xxxxx: [0.2] pri=0 flags=0 cpu=3 credit=-48 [w=256] ... This means the active vcpu 0.2 became non-active with the active list element empty just after it was accessed in the loop '2:'. We should always hold a lock before access scheduler related list, even in the debug purpose dump code. Signed-off-by: Wei Gang --- diff --git a/xen/common/sched_credit.c b/xen/common/sched_credit.c index d4852fd707..0cbc7e1342 100644 --- a/xen/common/sched_credit.c +++ b/xen/common/sched_credit.c @@ -1452,6 +1452,10 @@ csched_dump(const struct scheduler *ops) struct list_head *iter_sdom, *iter_svc; struct csched_private *prv = CSCHED_PRIV(ops); int loop; + unsigned long flags; + + spin_lock_irqsave(&(prv->lock), flags); + #define idlers_buf keyhandler_scratch printk("info:\n" @@ -1500,6 +1504,8 @@ csched_dump(const struct scheduler *ops) } } #undef idlers_buf + + spin_unlock_irqrestore(&(prv->lock), flags); } static int